/**
 * 
 * 广州锐鹏计算机科技有限公司（www.ruipengkj.com）
 * 
 * 
 * Copyright (c) 2011-2012 RUIPENGKJ.Co.Ltd. All rights reserved.
 * 
 * */
package com.ruipengkj.dao.impl;

import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.stereotype.Repository;

import com.ruipengkj.bean.TOrder;
import com.ruipengkj.commons.dao.GenericDao;
import com.ruipengkj.dao.TOrderDao;
/**
 * 说明：
 * 定单dao层接口
 * @Author：李智深
 * @Date：2012-03-16
 */
@Repository
public class TOrderDaoImpl extends GenericDao<TOrder,String> implements TOrderDao {


	@Override
	public Double findCashAmountByWorkShiftID(String WorkShiftID) {
		Session session = getHiberanteTemplate().getSessionFactory().openSession();
		Query query = session.createSQLQuery("select sum(PayedAmount) form ruipeng_tb_torder where WorkShiftID = ? and PayWay = 7");
		query.setParameter(0, WorkShiftID);
		return (Double) query.uniqueResult();
	}

	@Override
	public Double findDiscountAmountByWorkShiftID(String WorkShiftID) {
		Session session = getHiberanteTemplate().getSessionFactory().openSession();
		Query query = session.createSQLQuery("select sum(DiscountAmount) form ruipeng_tb_torder where WorkShiftID = ?");
		query.setParameter(0, WorkShiftID);
		return (Double) query.uniqueResult();
	}

	@Override
	public Integer findOrderCountByWorkShiftID(String WorkShiftID) {
		Session session = getHiberanteTemplate().getSessionFactory().openSession();
		Query query = session.createSQLQuery("select count(*) form ruipeng_tb_torder where WorkShiftID = ?");
		query.setParameter(0, WorkShiftID);
		return (Integer) query.uniqueResult();
	}

	@Override
	public Double findCardAmountByWorkShiftID(String WorkShiftID) {
		// TODO Auto-generated method stub
		return null;
	}
}
